package edu.sctu.zhoumengxue.day201506.day20150614.Filepractice;

import java.io.File;

/**
 * Created by user12 on 2015/6/14.
 */
public class FilePath {
    public static void main(String[] args) {

        File file = new File("D://more");
        if (file.isDirectory()){
            System.out.println(file.getPath());//路径
            System.out.println(file.getName());//目录名称
            System.out.println(file.getParentFile());
            System.out.println(file.getParent());
        }
/*列出所有目录下的文件路径*/
        File files[] = file.listFiles();
        for (int i = 0; i <files.length ; i++) {
            System.out.println(files[i]);
        }
        /*扫描目录*/

        String s = "D://more";
        File file1 = new File(s);
        fun(file1);

    }

    public static void fun(File file){
        if (file.isDirectory()){
            File files[] = file.listFiles();
           try{
               for (int i = 0; i <files.length ; i++) {
                   fun(files[i]);
               }
           }catch (Exception e){}
        }else {
            System.out.println(file);
        }
    }
}
